<template>
  <el-header>
    <el-menu class="el-menu-demo" mode="horizontal">
      <el-menu-item index="1" @click="home">首页</el-menu-item>
      <el-menu-item index="1" @click="product" >产品管理</el-menu-item>
      <el-menu-item index="1" @click="equipment" >设备管理</el-menu-item>
      <el-menu-item index="1" @click="order" >订单管理</el-menu-item>
      <el-menu-item index="1" @click="plan" >生产计划管理</el-menu-item>
      <el-menu-item index="1" @click="scheduling" >生产调度管理</el-menu-item>

    </el-menu>
  </el-header>
</template>

<script>
export default {
  name: "Top",
  data(){
    return{
      factoryId:this.$route.query.factoryId,
      user:{},
    }
  },
  created(){
    this.user = this.$getSessionStorage('user');
    console.log(this.user);
  },
  methods:{
    //用户的权限等级：1.全局管理员
    //2.产品管理员
    //3.设备管理员
    //4.订单管理员
    //5.计划与工单管理员
    home(){
      this.$router.push({path:"/home"})
    },
    product(){
      if(this.user.userLevel==1){
        this.$router.push({path:"/product",query:{factoryId:this.user.factoryId}})
      }
      if(this.user.userLevel==2){
        this.$router.push({path:"/product",query:{factoryId:this.user.factoryId}})
      }
      if(this.user.userLevel==3){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==4){
        this.$confirm("当前用户权限不足")
      }      
      if(this.user.userLevel==5){
        this.$confirm("当前用户权限不足")
      }
    },
    equipment(){
      if(this.user.userLevel==1){
        this.$router.push({path:"/equipment",query:{factoryId:this.user.factoryId}})
      }
      if(this.user.userLevel==2){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==3){
        this.$router.push({path:"/equipment",query:{factoryId:this.user.factoryId}})
      }
      if(this.user.userLevel==4){
        this.$confirm("当前用户权限不足")
      }      
      if(this.user.userLevel==5){
        this.$confirm("当前用户权限不足")
      }      

    },
    order(){
      if(this.user.userLevel==1){
        this.$router.push({path:"/order",query:{factoryId:this.user.factoryId}})
      }
      if(this.user.userLevel==2){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==3){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==4){
        this.$router.push({path:"/order",query:{factoryId:this.user.factoryId}})
      }      
      if(this.user.userLevel==5){
        this.$confirm("当前用户权限不足")
      } 

    },
    plan(){
     if(this.user.userLevel==1){
       this.$router.push({path:"/plan",query:{factoryId:this.user.factoryId}})
      }
      if(this.user.userLevel==2){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==3){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==4){
        this.$confirm("当前用户权限不足")
      }      
      if(this.user.userLevel==5){
        this.$router.push({path:"/plan",query:{factoryId:this.user.factoryId}})
      }       

    },
    scheduling(){
     if(this.user.userLevel==1){
        this.$router.push({path:"/scheduling"})
      }
      if(this.user.userLevel==2){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==3){
        this.$confirm("当前用户权限不足")
      }
      if(this.user.userLevel==4){
        this.$confirm("当前用户权限不足")
      }      
      if(this.user.userLevel==5){
        this.$router.push({path:"/scheduling"})
      }  

    },

  }
};
</script>

<style scoped></style>
